package com.springboot.jktj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.springboot.common.annotation.Log;
import com.springboot.common.core.controller.BaseController;
import com.springboot.common.core.domain.AjaxResult;
import com.springboot.common.enums.BusinessType;
import com.springboot.jktj.domain.JktjSetmeal;
import com.springboot.jktj.service.IJktjSetmealService;
import com.springboot.common.utils.poi.ExcelUtil;
import com.springboot.common.core.page.TableDataInfo;

/**
 * 体检套餐Controller
 * 
 * @author springboot
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/jktj/setmeal")
public class JktjSetmealController extends BaseController
{
    @Autowired
    private IJktjSetmealService jktjSetmealService;

    /**
     * 查询体检套餐列表
     */
    @PreAuthorize("@ss.hasPermi('jktj:setmeal:list')")
    @GetMapping("/list")
    public TableDataInfo list(JktjSetmeal jktjSetmeal)
    {
        startPage();
        List<JktjSetmeal> list = jktjSetmealService.selectJktjSetmealList(jktjSetmeal);
        return getDataTable(list);
    }

    /**
     * 导出体检套餐列表
     */
    @PreAuthorize("@ss.hasPermi('jktj:setmeal:export')")
    @Log(title = "体检套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JktjSetmeal jktjSetmeal)
    {
        List<JktjSetmeal> list = jktjSetmealService.selectJktjSetmealList(jktjSetmeal);
        ExcelUtil<JktjSetmeal> util = new ExcelUtil<JktjSetmeal>(JktjSetmeal.class);
        util.exportExcel(response, list, "体检套餐数据");
    }

    /**
     * 获取体检套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('jktj:setmeal:query')")
    @GetMapping(value = "/{setmId}")
    public AjaxResult getInfo(@PathVariable("setmId") Long setmId)
    {
        return success(jktjSetmealService.selectJktjSetmealBySetmId(setmId));
    }

    /**
     * 新增体检套餐
     */
    @PreAuthorize("@ss.hasPermi('jktj:setmeal:add')")
    @Log(title = "体检套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JktjSetmeal jktjSetmeal)
    {
        return toAjax(jktjSetmealService.insertJktjSetmeal(jktjSetmeal));
    }

    /**
     * 修改体检套餐
     */
    @PreAuthorize("@ss.hasPermi('jktj:setmeal:edit')")
    @Log(title = "体检套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JktjSetmeal jktjSetmeal)
    {
        return toAjax(jktjSetmealService.updateJktjSetmeal(jktjSetmeal));
    }

    /**
     * 删除体检套餐
     */
    @PreAuthorize("@ss.hasPermi('jktj:setmeal:remove')")
    @Log(title = "体检套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{setmIds}")
    public AjaxResult remove(@PathVariable Long[] setmIds)
    {
        return toAjax(jktjSetmealService.deleteJktjSetmealBySetmIds(setmIds));
    }
}
